package WaiBao;

import java.util.Arrays;

public class WangKeYan {
    public static void main(String[] args) {
        String[] name = {"李小乐(班长)", "王大炮(副班长)", "小李(学习委员)", "张小海(体育委员)", "王大夫", "梁家辉", "张学友", "梁朝伟", "张村发", "李富贵", "吴郑宇", "王大宝",
                "曹夫楼", "谢冰冰", "曹永强", "肖秀荣", "吴奇隆", "胖哥俩", "李忠祥", "张家峰", "李海乐", "海底捞", "燕双鹰", "李大虎", "倪大红", "张胖子", "扛把子", "王二狗",
                "肖战", "王科研(学生)"};//考生本人:王科研(学生)
        int[] age = {19,19, 21, 21, 22,21, 18, 18, 19, 20, 18, 19, 21, 22, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 21, 18, 20,21, 20, 20};//考生年龄：20

        double[] gaizi1 = {67, 72, 84, 90, 79, 69, 78, 89, 80, 80, 95, 87, 85, 89, 65, 64, 69, 89, 96, 88, 95, 91, 97, 65, 75, 74, 94, 74, 84, 95};
        double[] gaizi2 = {75, 75, 90, 76, 78, 77, 77, 69, 90, 70, 90, 77, 65, 95, 65, 65, 76, 79, 66, 90, 72, 71, 95, 86, 75, 88, 81, 64, 84, 97};
        double[] gaizi3 = {84, 76, 84, 85, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 75, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 94};


        double ddl1;//代表每个学生的总分
        double ddl2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            ddl1 = gaizi1[i] + gaizi2[i] +gaizi3[i];
//            ddl2 = ( ddl1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +  ddl1);
//            System.out.println(name[i] + "的平均分为:" +  ddl2);
//        }

        double wang1 = 0, wang2 = 0;
        double[] Arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            wang1 = gaizi1[i] + gaizi2[i] + gaizi3[i];
//            wang2 = (wang1 * 1.0) / 3;
//            Arr[i] = wang2;
//        }
//
//        for (int i = 0; i < Arr.length - 1; i++) {
//            for (int j = 0; j < Arr.length - i - 1; j++) {
//                if (Arr[j] < Arr[j + 1]) {
//                    double tep = Arr[j];
//                    Arr[j] = Arr[j + 1];
//                    Arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Arr[i]);
//        }



        double heidan1 = 0, heidan2 = 0, heidan3 = 0;//计算每门课的平均分
        double xiaobai1 = 0,xiaobai2 = 0, xiaobai3 = 0;//计算每门课标准差
        double dahu1 = 0, dahu2 = 0, dahu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <gaizi1.length; i++) {
            he += gaizi1[i];
        }
        heidan1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + heidan1);
        double Sum = 0;
        for (int i = 0; i < gaizi2.length; i++) {
            Sum += gaizi2[i];
        }
        heidan2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + heidan2);
        double sum = 0;
        for (int i = 0; i < gaizi3.length; i++) {
            sum += gaizi3[i];
        }
        heidan3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + heidan3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < gaizi1.length; i++) {
            c1 += (gaizi1[i] - heidan1) * (gaizi1[i] - heidan1);
        }
        xiaobai1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + xiaobai1);
        for (int i = 0; i <gaizi2.length; i++) {
            c2 += (gaizi2[i] - heidan2) * (gaizi2[i] - heidan2);
        }
        xiaobai2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + xiaobai2);

        for (int i = 0; i < gaizi3.length; i++) {
            c3 += (gaizi3[i] - heidan3) * (gaizi3[i] - heidan3);
        }
        xiaobai3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + xiaobai3);
////
//
//
        Arrays.sort(gaizi1);
        Arrays.sort(gaizi2);
        Arrays.sort(gaizi3);
        dahu1 = (gaizi1[14] + gaizi2[15]) * 1.0 / 2;
        dahu2 = (gaizi2[14] + gaizi2[15]) * 1.0 / 2;
        dahu3 = (gaizi3[14] + gaizi3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + dahu1);
        System.out.println("物理化学的中位数为:" + dahu2);
        System.out.println("电子与电工技术的中位数为:" + dahu3);




    }
}
